from selenium.webdriver.common.by import By
from utils.page_base import PageBase



class PageConcat(PageBase):
    def __init__(self,driver):
        PageBase.__init__(self,driver)
        self.driver=driver

    #元素特征
    loc_bendibaocun=By.XPATH,"text,本地保存,1"
    loc_addConcat=By.ID,"com.android.contacts:id/floating_action_button"
    loc_name=By.XPATH,"text,姓名,1"
    loc_nicen=By.XPATH,"text,昵称,1"
    loc_phone=By.XPATH,"text,电话,1"
    loc_email=By.XPATH,"text,电子邮件,1"
    loc_addr=By.XPATH,"text,地址,1"
    loc_company=By.XPATH,"text,公司,1"
    loc_beizu=By.XPATH,"text,备注,1"
    loc_fanhuijiantou=By.CLASS_NAME,"android.widget.ImageButton"
    loc_assert01=By.ID,"com.android.contacts:id/large_title"

    def click_bendibaocun(self):
        self.click(loc=PageConcat.loc_bendibaocun)

    # 定位元素“添加联系人”，并点击
    def click_addConcat(self):
        self.click(loc=PageConcat.loc_addConcat)

    # 定位元素“姓名”，并输入
    def input_name(self,name):
        self.input_text(loc=PageConcat.loc_name,text=name)

    # 定位元素“昵称”，并输入
    def input_nicen(self,nicen):
        self.input_text(loc=PageConcat.loc_nicen,text=nicen)

    # 定位元素“手机号”，并输入
    def input_phone(self,phone):
        self.input_text(loc=PageConcat.loc_phone,text=phone)

    # 定位元素“邮箱”，并输入
    def input_email(self,email):
        self.input_text(loc=PageConcat.loc_email,text=email)

    # 定位元素“地址”，并输入
    def input_addr(self,addr):
        self.input_text_scroll(loc=PageConcat.loc_addr,data=addr)

    # 定位元素“公司”，并输入
    def input_company(self,company):
        self.input_text_scroll(loc=PageConcat.loc_company,data=company)

    # 定位元素“备注”，并输入
    def input_beizu(self,beizu):
        self.input_text_scroll(loc=PageConcat.loc_beizu,data=beizu)

    # 定位元素“返回箭头”，并点击
    def click_fanhuijiantou(self):
        self.click(loc=PageConcat.loc_fanhuijiantou)

    def assert_001(self,name):
        ele=self.find_element(loc=PageConcat.loc_assert01)
        siji=ele.text
        return siji==name;